package kit.edu.lego.gruppe3.levels.endzone;

import kit.edu.lego.gruppe3.ComponentsRepository;
import kit.edu.lego.gruppe3.levels.LevelSelector;
import lejos.nxt.TouchSensor;
import lejos.robotics.navigation.DifferentialPilot;
import lejos.robotics.subsumption.Behavior;

public class HitFrontWall implements Behavior
{

	private TouchSensor leftTouchS = ComponentsRepository.getInstance().getLeftTouchSensor();
	private TouchSensor rightTouchS = ComponentsRepository.getInstance().getRightTouchSensor();
	private DifferentialPilot robot = ComponentsRepository.getInstance().getRobotPilot();
	
	private boolean leftHit = false;
	private boolean rightHit = false;
	
	@Override
	public void action()
	{

		robot.setTravelSpeed(10);
		robot.travel(-1.5f);
		robot.rotate(110);

	}

	@Override
	public void suppress()
	{
	}

	@Override
	public boolean takeControl()
	{
		leftHit = leftTouchS.isPressed();
		rightHit = rightTouchS.isPressed();
		return LevelSelector.getInstance().isEndZone() &&
			(leftHit || rightHit);
	}

}
